package com.seanLab.domain;

import com.seanLab.dto.SuggestArticleKeywordsDto;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by ailly on 17-10-6.
 */
@Document(collection = "editorSession")
public class EditorSession implements Serializable {
    @Id
    private String sessionID;

    private Date recommendDate;
    private String title;
    private String content;
    private String url;
    private List<SuggestArticleKeywordsDto> keywords;
    private List<String> recommendedImgs;
    private List<RecommendedImg> recImgs;

    class RecommendedImg {
        String imgID;
        List<String> tagID;
        List<String> tagName;

        public String getImgID() {
            return imgID;
        }

        public void setImgID(String imgID) {
            this.imgID = imgID;
        }

        public List<String> getTagID() {
            return tagID;
        }

        public void setTagID(List<String> tagID) {
            this.tagID = tagID;
        }

        public List<String> getTagName() {
            return tagName;
        }

        public void setTagName(List<String> tagName) {
            this.tagName = tagName;
        }
    }

    public EditorSession() {
    }

    public EditorSession(String sessionID, Date recommendDate, String title, String content, String url, List<SuggestArticleKeywordsDto> keywords, List<String> recommendedImgs, List<RecommendedImg> recImgs) {
        this.sessionID = sessionID;
        this.recommendDate = recommendDate;
        this.title = title;
        this.content = content;
        this.url = url;
        this.keywords = keywords;
        this.recommendedImgs = recommendedImgs;
        this.recImgs = recImgs;
    }

    public List<SuggestArticleKeywordsDto> getKeywords() {
        return keywords;
    }

    public void setKeywords(List<SuggestArticleKeywordsDto> keywords) {
        this.keywords = keywords;
    }

    public String getSessionID() {
        return sessionID;
    }

    public void setSessionID(String sessionID) {
        this.sessionID = sessionID;
    }

    public Date getRecommendDate() {
        return recommendDate;
    }

    public void setRecommendDate(Date recommendDate) {
        this.recommendDate = recommendDate;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public List<String> getRecommendedImgs() {
        return recommendedImgs;
    }

    public void setRecommendedImgs(List<String> recommendedImgs) {
        this.recommendedImgs = recommendedImgs;
    }

    public List<RecommendedImg> getRecImgs() {
        return recImgs;
    }

    public void setRecImgs(List<RecommendedImg> recImgs) {
        this.recImgs = recImgs;
    }

    public List<String> getInnerImgTagIDs(int imgIndex) {
        return this.recImgs.get(imgIndex).getTagID();
    }

    public void addInnerImg(String imgID, List<String> tagIDs, List<String> tagNames) {
        RecommendedImg rc = new RecommendedImg();
        rc.setImgID(imgID);
        rc.setTagID(tagIDs);
        rc.setTagName(tagNames);
        this.recImgs.add(rc);
    }

    public void initInnerImg(){
        List<RecommendedImg> rci = new ArrayList<>();
        this.recImgs = rci;
    }
}
